﻿/*
Post-Deployment Script Template							
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script.		
 Use SQLCMD syntax to include a file in the post-deployment script.			
 Example:      :r .\myfile.sql								
 Use SQLCMD syntax to reference a variable in the post-deployment script.		
 Example:      :setvar TableName MyTable							
               SELECT * FROM [$(TableName)]					
--------------------------------------------------------------------------------------
*/

IF NOT EXISTS(SELECT deviation_percent_id FROM meta.DeviationPercent)
BEGIN
	PRINT 'Setting default values for DeviationPercent';
	SET IDENTITY_INSERT [meta].[DeviationPercent] ON;

	INSERT INTO [meta].[DeviationPercent]
	(deviation_percent_id, val_min,val_max)
	VALUES
	(0, '0', '0.1725'), 
	(1, '0.1725', '0.370875'), 
	(2, '0.370875', '0.599006'), 
	(3, '0.599006', '0.861357'), 
	(4, '0.861357', '1.16306'), 
	(5, '1.16306', '1.51002'), 
	(6, '1.51002', '1.90902'), 
	(7, '1.90902', '2.36788'), 
	(8, '2.36788', '2.89556'), 
	(9, '2.89556', '3.50239'), 
	(10, '3.50239', '4.20025'), 
	(11, '4.20025', '5.00279'), 
	(12, '5.00279', '5.92571'), 
	(13, '5.92571', '6.98706'), 
	(14, '6.98706', '8.20762'), 
	(15, '8.20762', '9.61126'), 
	(16, '9.61126', '11.2255'), 
	(17, '11.2255', '13.0818'), 
	(18, '13.0818', '15.2165'), 
	(19, '15.2165', '17.6715'), 
	(20, '17.6715', '20.4947'), 
	(21, '20.4947', '23.7415'), 
	(22, '23.7415', '27.4752'), 
	(23, '27.4752', '31.769'), 
	(24, '31.769', '36.7068'), 
	(25, '36.7068', '42.3853'), 
	(26, '42.3853', '48.9156'), 
	(27, '48.9156', '56.4255'), 
	(28, '56.4255', '65.0618'), 
	(29, '65.0618', '74.9935'), 
	(30, '74.9935', '86.4151'), 
	(31, '86.4151', '99.5498'), 
	(32, '99.5498', '114.655'), 
	(33, '114.655', '132.026'), 
	(34, '132.026', '152.002'), 
	(35, '152.002', '174.975'), 
	(36, '174.975', '201.393'), 
	(37, '201.393', '231.775'), 
	(38, '231.775', '266.714'), 
	(39, '266.714', '306.893'), 
	(40, '306.893', '353.1'), 
	(41, '353.1', '406.237'), 
	(42, '406.237', '467.345'), 
	(43, '467.345', '537.619'), 
	(44, '537.619', '618.435'), 
	(45, '618.435', '711.372'), 
	(46, '711.372', '818.251'), 
	(47, '818.251', '941.161'), 
	(48, '941.161', '1082.51'), 
	(49, '1082.51', '1245.06'), 
	(50, '1245.06', '1431.99'), 
	(51, '1431.99', '1646.96'), 
	(52, '1646.96', '1894.17'), 
	(53, '1894.17', '2178.47'), 
	(54, '2178.47', '2505.42'), 
	(55, '2505.42', '2881.4'), 
	(56, '2881.4', '3313.78'), 
	(57, '3313.78', '3811.02'), 
	(58, '3811.02', '4382.85'), 
	(59, '4382.85', '5040.45'), 
	(60, '5040.45', '5796.69'), 
	(61, '5796.69', '6666.36'), 
	(62, '6666.36', '7666.49'), 
	(63, '7666.49', '8816.64'), 
	(64, '8816.64', '10139.3'), 
	(65, '10139.3', '11660.4'), 
	(66, '11660.4', '13409.6'), 
	(67, '13409.6', '15421.2'), 
	(68, '15421.2', '17734.6'), 
	(69, '17734.6', '20394.9'), 
	(70, '20394.9', '23454.3'), 
	(71, '23454.3', '26972.7'), 
	(72, '26972.7', '31018.7'), 
	(73, '31018.7', '35671.7'), 
	(74, '35671.7', '41022.6'), 
	(75, '41022.6', '47176.2'), 
	(76, '47176.2', '54252.8'), 
	(77, '54252.8', '62390.9'), 
	(78, '62390.9', '71749.7'), 
	(79, '71749.7', '82512.4'), 
	(80, '82512.4', '94889.4'), 
	(81, '94889.4', '109123'), 
	(82, '109123', '125492'), 
	(83, '125492', '144315'), 
	(84, '144315', '165963'), 
	(85, '165963', '190858'), 
	(86, '190858', '219486'), 
	(87, '219486', '252410'), 
	(88, '252410', '290271'), 
	(89, '290271', '333812'), 
	(90, '333812', '383884'), 
	(91, '383884', '441467'), 
	(92, '441467', '507687'), 
	(93, '507687', '583840'), 
	(94, '583840', '671416'), 
	(95, '671416', '772129'), 
	(96, '772129', '887949'), 
	(97, '887949', '1.02114e+006'), 
	(98, '1.02114e+006', '1.17431e+006'), 
	(99, '1.17431e+006', '1.35046e+006'), 
	(100, '1.35046e+006', '1.55303e+006'), 
	(101, '1.55303e+006', '1.78598e+006'), 
	(102, '1.78598e+006', '2.05388e+006'), 
	(103, '2.05388e+006', '2.36196e+006'), 
	(104, '2.36196e+006', '2.71626e+006'), 
	(105, '2.71626e+006', '3.1237e+006'), 
	(106, '3.1237e+006', '3.59225e+006'), 
	(107, '3.59225e+006', '4.13109e+006'), 
	(108, '4.13109e+006', '4.75075e+006'), 
	(109, '4.75075e+006', '5.46336e+006'), 
	(110, '5.46336e+006', '6.28287e+006'), 
	(111, '6.28287e+006', '7.2253e+006'), 
	(112, '7.2253e+006', '8.3091e+006'), 
	(113, '8.3091e+006', '9.55546e+006'), 
	(114, '9.55546e+006', '1.09888e+007'), 
	(115, '1.09888e+007', '1.26371e+007'), 
	(116, '1.26371e+007', '1.45327e+007'), 
	(117, '1.45327e+007', '1.67126e+007'), 
	(118, '1.67126e+007', '1.92194e+007'), 
	(119, '1.92194e+007', '2.21024e+007'), 
	(120, '2.21024e+007', '2.54177e+007'), 
	(121, '2.54177e+007', '2.92304e+007'), 
	(122, '2.92304e+007', '3.36149e+007'), 
	(123, '3.36149e+007', '3.86572e+007'), 
	(124, '3.86572e+007', '4.44557e+007'), 
	(125, '4.44557e+007', '5.11241e+007'), 
	(126, '5.11241e+007', null);
	SET IDENTITY_INSERT [meta].[DeviationPercent] OFF;
END

IF NOT EXISTS(SELECT perfmon_counter_id FROM perf.PerfmonCounter)
BEGIN
	PRINT 'Setting default values for PerfmonCounter';
	INSERT INTO perf.PerfmonCounter
		(perfmon_object,perfmon_counter_name)
	VALUES
		('LogicalDisk', '% Free Space'),
		('LogicalDisk', '% Idle Time'),
		('LogicalDisk', 'Avg. Disk Queue Length'),
		('LogicalDisk', 'Avg. Disk sec/Read'),
		('LogicalDisk', 'Avg. Disk sec/Transfer'),
		('LogicalDisk', 'Avg. Disk sec/Write'),
		('LogicalDisk', 'Current Disk Queue Length'),
		('LogicalDisk', 'Disk Bytes/sec'),
		('LogicalDisk', 'Disk Reads/sec'),
		('LogicalDisk', 'Disk Writes/sec'),
		('LogicalDisk', 'Free Megabytes'),
		('Memory', '% Committed Bytes In Use'),
		('Memory', 'Available Bytes'),
		('Memory', 'Available MBytes'),
		('Memory', 'Cache Bytes'),
		('Memory', 'Cache Faults/sec'),
		('Memory', 'Committed Bytes'),
		('Memory', 'Page Faults/sec'),
		('Memory', 'Page Reads/sec'),
		('Memory', 'Page Writes/sec'),
		('Memory', 'Pages/sec'),
		('Memory', 'Pool Nonpaged Bytes'),
		('Memory', 'Pool Paged Bytes'),
		('Network Interface', 'Bytes Received/sec'),
		('Network Interface', 'Bytes Sent/sec'),
		('Network Interface', 'Bytes total/sec'),
		('Network Interface', 'Output Queue Length'),
		('Network Interface', 'Packets Received/sec'),
		('Network Interface', 'Packets Sent/sec'),
		('Paging File', '% Usage'),
		('PhysicalDisk', '% Disk Read Time'),
		('PhysicalDisk', '% Disk Time'),
		('PhysicalDisk', '% Disk Write Time'),
		('PhysicalDisk', 'Avg. Disk Bytes/Read'),
		('PhysicalDisk', 'Avg. Disk Bytes/Write'),
		('PhysicalDisk', 'Avg. Disk Queue Length'),
		('PhysicalDisk', 'Avg. Disk Read Queue Length'),
		('PhysicalDisk', 'Avg. Disk Sec/Read'),
		('PhysicalDisk', 'Avg. Disk sec/Transfer'),
		('PhysicalDisk', 'Avg. Disk Sec/Write'),
		('PhysicalDisk', 'Avg. Disk Write Queue Length'),
		('PhysicalDisk', 'Current Disk Queue Length'),
		('PhysicalDisk', 'Disk Bytes/sec'),
		('PhysicalDisk', 'Disk Read Bytes/sec'),
		('PhysicalDisk', 'Disk Reads/sec'),
		('PhysicalDisk', 'Disk Transfers/sec'),
		('PhysicalDisk', 'Disk Write Bytes/sec'),
		('PhysicalDisk', 'Disk Writes/sec'),
		('Processor', '% DPC Time'),
		('Processor', '% Interrupt Time'),
		('Processor', '% Privileged Time'),
		('Processor', '% Processor Time'),
		('Processor', '% User Time'),
		('Processor', 'Interrupts/sec'),
		('SQL Server', 'Connections'),
		('SQL Server', 'Database size'),
		('SQL Server', 'Database status'),
		('SQLServer:Access Methods', 'Full Scans/sec'),
		('SQLServer:Backup Device', 'Device Throughput Bytes/sec'),
		('SQLServer:Buffer Manager', 'Buffer Cache Hit Ratio'),
		('SQLServer:Databases', 'Transactions/sec'),
		('SQLSERVER:General Statistics', 'Logins/sec'),
		('SQLServer:General Statistics', 'Processes blocked'),
		('SQLServer:General Statistics', 'Transactions/sec'),
		('SQLSERVER:General Statistics', 'User Connections'),
		('SQLServer:Latches', 'Average Latch Wait Time (ms)'),
		('SQLSERVER:Locks', 'Lock Requests/sec'),
		('SQLServer:Locks', 'Lock Timeouts/sec'),
		('SQLServer:Locks', 'Lock Waits/sec'),
		('SQLServer:Locks', 'Number of Deadlocks/sec'),
		('SQLServer:Memory Manager', 'Total Server Memory (KB)'),
		('SQLServer:SQL Errors', 'Errors/sec'),
		('SQLServer:SQL Statistics', 'Batch Requests/sec'),
		('SQLSERVER:SQL Statistics', 'SQL Compilations/sec'),
		('SQLServer:SQL Statistics', 'SQL Re-Compilations/sec')
END